package com.qqcommon;

import java.util.Scanner;
@SuppressWarnings({"all"})
/**
 * 客户端的窗口显示
 *
 */

public class QQView {
    public static void main(String[] args) {
        new QQView().mainMenu();
        System.out.println("客户端退出");
    }
    private boolean loop=true;//控制显示主菜单
    private UserClientServer userClientServer=new UserClientServer();//用于登录服务器/注册用户
    private int key=0;

    //显示主菜单
    private  void mainMenu(){
        Scanner scanner=new Scanner(System.in);//用户输入
        do{
            System.out.println("======QQ登录界面======");
            System.out.println("\t\t1.登录QQ");
            System.out.println("\t\t9.退出QQ");
            System.out.println("请选择:");
            key=scanner.nextInt();

            switch(key){
                case 1:
                    System.out.println("======QQ登录界面======");
                    System.out.print("请输入用户名:");
                    String userid=scanner.next();
                    System.out.print("请输入密    码:");
                    String pwd=scanner.next();
                    //这里先省略一万行
                    //涉及对用户的核查
                    //userClientServer.checkUser(userid,pwd)
                    if(userClientServer.checkUser(userid,pwd)){//登录成功
                        System.out.println("======欢迎"+userid+"======");
                        //进入二级菜单
                        do{
                            System.out.println("==========QQ登录二级菜单用户"+userid+"=================");
                            System.out.println("\t\t1.显示所有在线用户列表");
                            System.out.println("\t\t2.群发消息");
                            System.out.println("\t\t3.私聊消息");
                            System.out.println("\t\t4.发送文件");
                            System.out.println("\t\t9.退出系统");
                            System.out.println("请输入的你的选择:");
                            key=scanner.nextInt();

                            switch(key){
                                case 1:
                                    System.out.println("显示所有在线用户列表");
                                    break;
                                case 2:
                                    System.out.println("群发消息");
                                    break;
                                case 3:
                                    System.out.println("私聊消息");
                                    break;
                                case 4:
                                    System.out.println("发送文件");
                                    break;
                                case 9:
                                    System.out.println("退出系统");
                                    loop=false;
                                    break;
                                default :
                                    System.out.println("输入有误,请重新选择:");
                                    break;
                            }

                        }while(loop);

                    }
                    else{
                        System.out.println("======QQ登录失败======");
                        //登录失败
                    }


                    break;
                case 9:
                    loop=false;
                    break;
            }

        }while(loop);

    }
}
